/*
 * File Name : file_system.cpp
 * Auther : dream.liuguobiao
 * Create Date : 2010-5-17
 * Last Edit : 2010-5-17
 */

#include <unistd.h>
#include <iostream>

#include "halt.h"

halt::halt( std::string *new_parameters)
:command(new_parameters)
{
}

int halt::run_command(){
  std::stack<user*> *login_users = get_shell_environment()->get_login_users();
  user *current_user = login_users->top();

  if( current_user == get_shell_environment()->get_administrator()){
    sleep(1);
    std::cout<<"system now going to  halt..............................................[OK]\n";
/*
    sleep(1);
    std::cout<<"INIT: Entering runlevel:5..............................................[OK]\n";
    sleep(1);
    std::cout<<"Entering non - interactive startup.....................................[OK]\n";
    sleep(1);
    std::cout<<"Checking for new hardware changes......................................[OK]\n";
    sleep(1);
    std::cout<<"System Now Halted ~!...................................................[OK]\n";
    sleep(2);
*/
    std::cout<<std::endl;
    return 9;
  }
  else {
    std::cout<<"halt: must be superuser.\n";
    return 0;
  }
}
